home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / pt04bp22.zip / pterm.txt < prev    next >
Text File  |  1994-10-16  |  27KB  |  578 lines

  1.  
  2.  
  3.  
  4.                                   P T e r m
  5.  
  6.                          Paragon Terminal Application
  7.  
  8.                                 for Windows NT
  9.  
  10.                                Version 0.4bp22
  11.  
  12.                                16, October 1994
  13.  
  14.  
  15.  
  16.  
  17. *************************************************************************
  18.           Note: Please read the file RELNOTES.TXT before using PTerm. It
  19.                 contains important information on known bugs and
  20.                 limitations in this release of PTerm, as well as the 
  21.                 new features in this version.
  22. *************************************************************************
  23.  
  24.  
  25.    What's Going on Here?
  26.    =====================
  27.  
  28.       This is a beta of Paragon Terminal Application for Windows NT. What's
  29.       so great about PTerm? Not much yet, but here is a list of features
  30.       available so far:
  31.  
  32.          o  Fully threaded, native Win32 application
  33.  
  34.          o  Auto Zmodem download/upload with crash recovery and
  35.             auto-renaming of incoming files which already exist.
  36.  
  37.          o  Fast(er) ANSI (including color!) terminal emulation
  38.  
  39.          o  Simple sound support in the form of being able to
  40.             specify a [separate] wav file to play for both a
  41.             completed download as well as a completed download.
  42.  
  43.          o  Console based for speed
  44.  
  45.          o  TELNET support
  46.  
  47.       The other valuable feature of PTerm is that as far as I know it is
  48.       the only Zmodem capable native, multi-threaded Win32 terminal
  49.       application available. It won't be for long, but for now...
  50.  
  51.  
  52.       Some glaring omissions:
  53.  
  54.          o  No Dialer!?!?!
  55.  
  56.          o  No annoying "register me now, or die" messages and
  57.             purposefully broken features.
  58.  
  59.          o  Many other things which you will likely go insane without (but
  60.             hang in there, it is my intention to evolve PTerm).
  61.  
  62.  
  63.    About This Manual!
  64.    ==================
  65.  
  66.       This is the sorriest excuse for manual yet -- but I am anxious to
  67.       get this PTerm out to everyone, I'm not a tech-writer, and PTerm
  68.       isn't all that compilcated. So if after reading this text you have
  69.       the feeling that it was a poorly organized jumble of information,
  70.       well, your feeling is correct. What I do hope this manual will do
  71.       for you is to give you just enough information to get started using
  72.       PTerm. If it doesn't, please email me and I will be happy to answer
  73.       your questions (see my addresses below).
  74.  
  75.  
  76.    Why Would You Do Such a Thing?
  77.    ==============================
  78.  
  79.       Some months back, I was asked to beta test a C++ based,
  80.       multi-platform communications library from a company called Lookout
  81.       Mountain Software (William Herrera, owner/author, BBS 719-545-8572).
  82.  
  83.       The best method I could think of for testing this package was to use
  84.       it as the core of a terminal application -- and PTerm was born.
  85.  
  86.       William has been extremely sensitive to the problems I found and
  87.       enhancements I suggested, and should be commended for authoring such
  88.       a stable and comprehensive communications library, which is available
  89.       for DOS, Windows, OS/2 and Windows NT. All of the file transfer
  90.       protocol code (Zmodem/Ymodem/Xmodem) is Williams, and he has done an
  91.       excellent job implementing them (sealink and telink are also included
  92.       in the communications library, but not in PTerm -- Xmodem and Ymodem
  93.       will be available in the next release of PTerm).
  94.  
  95.  
  96.    I Didn't Do It, I Swear!
  97.    ========================
  98.  
  99.       Every precaution has been taken to ensure the safe operation of
  100.       PTerm in your Windows NT system. But, come'on, this copy of PTerm
  101.       in beta, and I'm warning you of such, so obviously I cannot be
  102.       held responsible for any damage done to your system (or psyche) by
  103.       PTerm or any interaction involving PTerm. So all I can say is "I
  104.       didn't do it!", so don't blame me!
  105.  
  106.  
  107.    What Do I Need To Use PTerm?
  108.    ============================
  109.  
  110.       You need an Intel based (Intel Inside sticker optional) PC running
  111.       Windows NT (August '93 build or later), with at least one serial port
  112.       and a modem attached to that port. Actually, if you just want to use
  113.       PTerm for TELNET you won't even need a serial port. However, I do
  114.       not recommend using PTerm for any but the simplist of tasks while
  115.       telneting.
  116.  
  117.       If someone would like to send me a MIPS R4400 or DEC Alpha AXP, I
  118.       will be glad to get PTerm up on those platforms as well <grin>.
  119.  
  120.       Actually, I have had a number of requests for PTerm on the Alpha
  121.       (surprisingly none for MIPS). My standard answer is that I don't
  122.       have an Alpha machine and that since PTerm is based largely on a
  123.       commercial library, I am not in a position to give the source to
  124.       someone with an Alpha. This is too bad, but it will have to do for
  125.       now...
  126.  
  127.  
  128.    Alright, What Do You Want For This?
  129.    ===================================
  130.  
  131.       The list of things I want would be much too large to include in this
  132.       document, so you will have to settle for what I need.
  133.  
  134.       What I need, from you, is the following:
  135.  
  136.          o  Bug reports (there should be plenty)
  137.          o  Suggestions (again, no shortage expected here either)
  138.  
  139.       So, please, please inundate me with this information, I promise I
  140.       will consider anything submitted (but nothing not submitted).
  141.  
  142.  
  143.    Whereami?
  144.    =========
  145.  
  146.       I can be reached via internet mail at:
  147.  
  148.          urjc!rjc@pcg.com
  149.          rjc@pcg.com
  150.          roncox@indirect.com
  151.          rjc@infograph.com
  152.          urjc!rjc@pcg.com
  153.  
  154.       FIDOnet people, try netmail to UUCP at 1:1/31, first line of the
  155.       message body:
  156.  
  157.          To: roncox@indirect.com
  158.  
  159.       I plan on finding a reliable FIDOnet system here in town, and when I
  160.       do I will post my FIDOnet address for netmail.
  161.  
  162.       You can reach me on Compuserve at:
  163.  
  164.          71722,3175
  165.  
  166.       For slowest response, choose snail-mail:
  167.  
  168.          Ron Cox
  169.          ATTN: PTerm
  170.          Paragon Consulting Group
  171.          4212 West Cactus STE 1110-229
  172.          Phoenix, AZ  85029
  173.  
  174.         If you write me, and you have any electronic email address at
  175.         all, please let me know what it is, chances are I can get to
  176.       you through it -- I am real bad about replying via U.S. Mail.
  177.  
  178.  
  179.    I'm Getting Sleeeepy...
  180.    =======================
  181.  
  182.       I know, I know -- I will make this easy on you (and me) and keep
  183.       things real short.
  184.  
  185.       First, a couple of command line switches have been added to PTerm.
  186.       They are:
  187.  
  188.            -s
  189.                Go straight into the setup dialog. When PTerm is first run
  190.                on your system, it will not find a PTerm.INI file to read
  191.                configuration from. If you have a COM1, this is no problem
  192.                since PTerm will default to COM1 and run, at which point
  193.                you can press ALT-S to run through the setup (see below).
  194.                However, if you have no COM1, PTerm will complain and then
  195.                exit. Passing the '-s' option bypasses the check and lets
  196.                you configure PTerm straight away.
  197.  
  198.            -ifile
  199.  
  200.                Since PTerm keeps its setup data in an ini file, I needed
  201.                some method of allowing multiple copies of PTerm to run.
  202.                PTerm normally defaults to looking for PTerm.INI in the
  203.                \WINNT directory. By passing a '-ifile' switch, you can
  204.                change which ini file PTerm will use. For instance, if
  205.                PTerm.INI sets up PTerm for COM1, and you also want to run
  206.                PTerm on COM2, you can copy PTerm.INI to PTerm2.INI and run
  207.                PTerm as such:
  208.  
  209.                      pterm -ipterm2.ini
  210.  
  211.                Note, the ini files MUST be in the \winnt directory, and
  212.                you must pass only the name (not the path) with the '-i'
  213.                switch.
  214.  
  215.       As is obvious from the discussion above, PTerm no longer uses
  216.       environment variables for configuration! So you can remove them all
  217.       from your PT.CMD (or master environment).
  218.  
  219.       PTerm configuration is now done through a set of dialog boxes. You
  220.       get to the main setup menu by pressing ALT-S. From here you can
  221.       choose to setup "Communications", "Modem Setup", "Macros", or "File
  222.       Transfers".
  223.  
  224.       All of the options in these setup dialogs are self explanatory (I
  225.       think), so I am not going to spend alot of time going over them. If
  226.       you have questions, just drop me some email and I will be happy to
  227.       help!
  228.  
  229.       The one area I would like to discuss is the "Macros". These are
  230.       literal strings which PTerm sends out when the appropriate key is
  231.       pressed (F1-F12) -- PTerm does NO fancy substitutions or expansions
  232.       on these these strings except to append a carriage return to them
  233.       before sending them out to the modem. The macro capability was added
  234.       out of guilt for not adding a dialer, and as such is useful for
  235.       defining upto 12 dial strings.
  236.  
  237.       Hitting ALT-C will show you the current settings as well as a list
  238.       of key commands (this is the same information which appears when
  239.       PTerm is first run).
  240.  
  241.       PTerm can be placed in (and executed from) the program manager, and
  242.       even has its own embedded icon (just like a real Windows program!).
  243.  
  244.       When using a batch enabled file transfer protocol (Zmodem), the file
  245.       selection dialog box which pops up for an upload will allow you to
  246.       select multiple files from any one directory, using the standard
  247.       Windows mouse/key combinations for multi-select lists (i.e. CTRL-CLICK
  248.       adds a file to the list, and try SHIFT-CLICK to extend the list to the
  249.       current point).
  250.  
  251.       For batch uploading, if PTerm finds a file called FILESTO.UPL in the
  252.       current directory (the directory you were in when you started PTerm),
  253.       it expects this file to contain a list of files (full paths) to
  254.       upload, and will attempt to do so. If PTerm finds this file, it will
  255.       go straight to uploading, bypassing the file selection dialog.
  256.  
  257.       I am sure I have forgotten a whole bunch of information here, but
  258.       this should be enough to get you off the ground.
  259.  
  260.  
  261.    Sound Support
  262.    =============
  263.  
  264.       Now on to the sound support which was added in version 04bp13. This
  265.       support takes the form of being able to assign a wav file for playing
  266.       when either a download or an upload completes.
  267.  
  268.       My first instinct for configuring this was to add a new setup dialog
  269.       to PTerm for assinging the sounds. Then I was looking in the Control Panel
  270.       "Sound" applet and thought it would be nice if the user could use this
  271.       standard interface for configuring the sounds PTerm will use.
  272.  
  273.       To make a long story short, I determined which part of the registry
  274.       needed to be appended to and wrote a small utility to make this easy
  275.       for the user to do (if you want lots of information on this, read the
  276.       file REGUSER.TXT). This utility is included with all PTerm distributions.
  277.  
  278.       Oh, ya, we're trying to make this story short... Ok, from the directory
  279.       where you unzipped PTerm into, run:
  280.  
  281.          ptsnd.cmd
  282.  
  283.       This will call the utility reguser.exe which should be in the same
  284.       directory. It will be run once to add the Download Completed entry
  285.       and once again for adding the Upload Completed entry. It sets the
  286.       default sound for each to <none>.
  287.  
  288.       Now, start up Control Panel and double click on the Sound applet.
  289.       You will find two new entries in the list, one called "Download
  290.       Completed" and one called "Upload Completed". Whatever you set
  291.       the sound to for each will be played when the action is completed
  292.       by PTerm.
  293.  
  294.       Note, you obviously must have a sound card which NT can use as a
  295.       wav output device. Also, the 'ptsnd.cmd' batch file above will
  296.       modify your registry -- I have made every attempt to insure that
  297.       it will not cause unwanted side-effects, however I will not accept
  298.       responsibility for any damage done to the users registry as a
  299.       result of running this software.
  300.  
  301.  
  302.    Can I Run it Now?
  303.    =================
  304.  
  305.       Well... Ok...
  306.  
  307.       But, "Don't touch it, you'll break it..." (U.S. West T.V. ad)
  308.  
  309.       For those of you who have been spoiled all their lives by a dialer and
  310.       do not know how to do it manually, if you have a modem which supports
  311.       the Hayes command set (are there any which don't?) you can dial a
  312.       number from PTerm like so:
  313.  
  314.          atdt555-5555               Tone dial 555-5555
  315.          atdp555-5555               Pulse dial 555-5555 (yuck!)
  316.  
  317.       On my USR Sportster, the command
  318.  
  319.          a/
  320.  
  321.       executes the last command entered, and can be used to redial.
  322.  
  323.       Again, you can add upto 12 dial strings as macros if you like.
  324.  
  325.       PTerm now has text capture. It is toggled by pressing ALT-L. When
  326.       activated, PTerm will bring up a standard Windows dialog box for
  327.       getting a file name. Enter a valid file path and click Ok. If you
  328.       are currently capturing text, the title bar of PTerm will have the
  329.       word "Capturing" at the end of it. Press ALT-L to close the capture
  330.       file. If you exit PTerm with an open capture file, PTerm will close
  331.       it for you before terminating.
  332.  
  333.       PTerm pretty much stores everything except ANSI escape sequences in
  334.       the capture file. Also, if you use a file which already exists,
  335.       PTerm will append captured text to that file without disturbing what
  336.       was already there.
  337.  
  338.  
  339.    Some Closing Thoughts
  340.    =====================
  341.  
  342.       Its not much, but there it is. Please let me know of any problems or
  343.       suggestions for enhancements you have.
  344.  
  345.       On my 386-33, running the NT GA (with USP2 installed), I have
  346.       experienced excellent transfer speeds using the Zmodem in PTerm. On
  347.       text files, at 14.4K with .v42bis (57.6K maximum), I have seen 3800+
  348.       cps. The same setup on compressed files yields 1650 cps and higher.
  349.       The NT serial driver is absolutely flawless in its support of
  350.       FIFO's. Make sure you have a serial card with a 16550AFN FIFO on it
  351.       and you will get much better file transfer results!
  352.  
  353.       Another facet of the serial driver which operates well is RTS/CTS
  354.       flow control. This is always turned on when PTerm runs, later it will
  355.       be configurable. During heavy multi-tasking, RTS/CTS keeps the modem
  356.       under control, holding it off when the serial buffer gets full. This
  357.       has worked flawlessly.
  358.  
  359.       Ron Cox
  360.       Paragon Consulting Group
  361.  
  362.  
  363.    Special Thanks
  364.    ==============
  365.  
  366.       To the following, I give special thanks:
  367.  
  368.          Dale Ross for being a sort of liason between Microsoft and myself
  369.          to get some nasty bugs fixed. Not to mention the extensive
  370.          testing he has done for me (also the other members of Team PTerm
  371.          <grin> -- Bob Chronister, Michael Rod, Stephen Purpura, and
  372.          Randall Kennedy)!
  373.  
  374.          Greg Kochaniak for his *extensive* help in getting PTerm's telnet
  375.          support to be even as useful as it is!
  376.  
  377.          To ALL the other people (especially on internet) who emailed me
  378.          with suggestions, and a couple even sent source code.
  379.  
  380.       Thanks!
  381.  
  382.  
  383.    Technically Speaking
  384.    ====================
  385.  
  386.       Thought you were done, didn't you? Well, if you could care less about
  387.       some of the technical details of PTerm, you are, else read on.
  388.  
  389.       As mentioned, PTerm makes full use of multi-threading. This stuff is a
  390.       trip. It can make programming much more interesting (and in many cases
  391.       greatly simplifies things!).
  392.  
  393.       There are 7 threads of execution, 6 secondary and the 1 main thread
  394.       which all Win32 applications start with.
  395.  
  396.       The first two threads of interest are in Williams communications
  397.       library. One is responsible for taking characters in from the serial
  398.       port (actually, the serial driver) and placing them in a queue created
  399.       by the library (the input queue) which is made visible to the user
  400.       code. The second takes characters from another queue and writes them
  401.       to the serial port (driver). The user code is responsible for placing
  402.       characters to be sent out the port into this output queue, and does so
  403.       through a set of 'Send' member functions.
  404.  
  405.       Also, both of Williams threads use overlapping (asynchronous) I/O,
  406.       resulting in an even more efficient set up.
  407.  
  408.       Now for the threads I spawn. They are as follows:
  409.  
  410.          o  Input thread
  411.  
  412.             Because I did not want to muck with the input queue being
  413.             managed by the communications library, I created another layer.
  414.             My input thread simply waits for characters to appear in the
  415.             main input queue, and block copies them into a local queue used
  416.             by the display thread (below). If there are no characters
  417.             waiting in the main input queue, this thread sleeps until there
  418.             is (in the discussions which follow, this thread will be
  419.             referred to as 'my input thread', to differentiate it from the
  420.             main input thread operating in the library). It may be that I
  421.             can increase PTerm's efficiency slightly by removing this layer
  422.             and having the display thread pull characters directly from the
  423.             library managed input queue -- something I will consider.
  424.  
  425.  
  426.          o  Display thread
  427.  
  428.             This thread is solely responsible for removing characters from
  429.             the local input queue (managed above) and deciding what to do
  430.             with them. For instance, if the beginning of an ANSI escape
  431.             sequence is detected this thread passes control to a function
  432.             whose job it is to interpret the sequence (note: the ANSI code
  433.             still executes within the display thread, no other thread has
  434.             been created). One of the other jobs of the display thread is
  435.             to optimize the output into the console window. This is done in
  436.             a very simplistic manner. In the absence of ANSI escape
  437.             sequences, the display thread will accumulate characters from
  438.             the local input queue into a buffer -- up to 80. When the
  439.             limit of 80 has been reached, or a special sequence is
  440.             detected, the display thread blasts the buffer to the screen in
  441.             a single call to WriteFile(). This is MUCH more efficient than
  442.             calling something like putch() for each single character.
  443.             However, at slow speeds (1200 and 2400 baud), it takes a
  444.             noticeable amount of time to accumulate 80 characters, and
  445.             this is the reason for the choppy display at these speeds. If
  446.             you set the port to anything less than 9600 baud, PTerm reduces
  447.             this 'blast' count to 8 characters, producing a smoother
  448.             display.
  449.  
  450.             As if this wasn't enough, the display thread has one more job to
  451.             perform. It watches for the tell-tale sequence of characters
  452.             which signal the host is preparing for a Zmodem upload or
  453.             download. If this sequence is found, it starts the appropriate
  454.             code.
  455.  
  456.             If there are no characters in the local input queue, the display
  457.             thread sleeps until there are.
  458.  
  459.  
  460.          o  User thread
  461.  
  462.             The user threads job is pretty easy. If the user hits a key,
  463.             decide what to do with it. Typically the key will be sent right
  464.             out the port. If it is a control key sequence (like ALT-X), then
  465.             the user thread executes the code appropriate for that key. This
  466.             thread blocks on the keyboard, and as such sleeps when there are
  467.             no characters available.
  468.  
  469.  
  470.          o  Main thread
  471.  
  472.             The main thread is the first thread which executes (starting in
  473.             main()). It initializes the port and other things, starts up the
  474.             three threads above, and then goes to sleep waiting for all
  475.             three of the threads above to terminate. At this point it wakes
  476.             up and calls ExitProcess(), ending PTerm.
  477.  
  478.  
  479.       Them's the threads, and a nice bunch of threads they are. However, if
  480.       there is one thing I quickly learned from spawning threads all over
  481.       the place, its that synchronization thingy.
  482.  
  483.       Here's the scenario: My input thread pulls characters from the main
  484.       input queue to place in the local input queue. Fair enough. So, I
  485.       start a Zmodem download. Boom! Of course, the Zmodem download code
  486.       also wants to pull characters from the main input queue, so my thread
  487.       fights with the Zmodem code. Remember, the Zmodem code is run as part
  488.       of the display thread. So my input thread grabs some characters, then
  489.       the Zmodem code [running in the display thread] grabs some
  490.       characters, and so on. Zmodem will end up missing a bunch of
  491.       characters it expected to see, and my input thread grab some
  492.       characters from the transfer which the display thread will finally
  493.       get and try to display. A mess...
  494.  
  495.       So, I need to find a way to synchronize the two threads. When Zmodem
  496.       wants control of the main input queue, it needs to 'ask' for control
  497.       from my input thread. Well, it really isn't as formal as all that.
  498.  
  499.       Just before my input thread grabs characters from the main input
  500.       queue, it waits on a semaphore. Simplified, a semaphore is just an
  501.       object which keeps count of how many threads have asked for control
  502.       of it. When its count is 0, access is granted to the waiting thread.
  503.       When a thread gets access to it, the semaphores count is incremented.
  504.       Any other thread which waits on it goes to sleep until the semaphores
  505.       count becomes 0 again. The count is decremented when a thread
  506.       explicitly releases a semaphore, thus allowing another thread to gain
  507.       access (this can get complicated when there are more than 2 threads).
  508.  
  509.       Ok, where were we? Oh, yes, my input thread waits on this semaphore
  510.       gadget. Typically, it gets control instantly and drops into the main
  511.       body of its code where it grabs characters from the main input queue
  512.       and stuffs them in the local queue the display thread uses. Once it
  513.       has transferred some characters, it releases the semaphore (and gives
  514.       up the rest of its time slice). Its during the time between releasing
  515.       the semaphore and waiting on it again that the file transfer code
  516.       must act.
  517.  
  518.       The first line of code for a file transfer waits on the same
  519.       semaphore. As soon as my input thread releases the semaphore, the file
  520.       transfer code gets and holds access to it until the transfer is
  521.       completed, thus preventing my input thread from mucking with the main
  522.       input queue during the transfer. Whew!
  523.  
  524.       Being this is my first foray into threads, I am very interested to
  525.       find out if my code breaks on a multi-processor machine. Does my code
  526.       work now because it takes advantage of the synchronous behavior of a
  527.       single processor? Interesting stuff, but I forgot to pick up my
  528.       Sequent 16 processor monster-box at the grocery store the other day,
  529.       so I suppose the answer will have to wait...
  530.  
  531.       I found one other interesting thing about Windows NT -- it seems to
  532.       like to write data to the disk right away. Generally, this is a good
  533.       thing, keeps your data safe. However, with Zmodem code writing 1K
  534.       blocks to disk every .7 seconds or so (at 1650 cps), the disk access
  535.       began to affect the performance of the download. The solution was
  536.       easy, I just used a call to setvbuf() to create a memory buffer. The
  537.       size I chose is 64K. So the system (C runtime) will accumulate 64K
  538.       bytes from the fwrite()'s before writing to disk. Believe it or not,
  539.       NT can actually write a 64K block to disk as quickly as a 1K block --
  540.       difference is, now Zmodem only hits the disk one a minute or so (at
  541.       1650 cps). Works great. Notice I said I made a 64K buffer. You 16 bit
  542.       guys probably have (as I did) the signed integer maximum value
  543.       memorized, 32K right? Well, under NT, a signed integer is 2^31, for a
  544.       maximum [signed] value of 2 GB. So 64K was small compared to what
  545.       I could make it.
  546.  
  547.       The file access areas of the transfer protocols are excellent
  548.       candidates for overlapped I/O, probably doing away with the need for a
  549.       write buffer. However, since Williams library is meant to be
  550.       multi-platform, it is best to keep it as generic as possible. But,
  551.       it is C++, and with proper inheritance the function responsible for
  552.       writing data to disk could be overloaded (and William has isolated
  553.       this operation for easy overloading!). A possible future enhancement
  554.       to PTerm.
  555.  
  556.       One more technical note: PTerm does not change its base priority
  557.       class, but it does manipulate the priority of several of its threads
  558.       relative to the priority class it is started at. What? Ok, if you run
  559.       PTerm from the command line like so:
  560.  
  561.          start pterm.exe
  562.  
  563.       then PTerm gets a base priority class of NORMAL. Using these commands:
  564.  
  565.          start /idle pterm.exe
  566.          start /normal pterm.exe
  567.          start /high pterm.exe
  568.          start /realtime pterm.exe
  569.  
  570.       You can change the base priority class which PTerm runs at.
  571.  
  572.       I strongly recommend leaving it at NORMAL priority (by using the
  573.       /normal switch, or not giving a priority at all). You are, of course,
  574.       free to experiment.
  575.  
  576.       Well, the rest of PTerm is plain and boring (as if the preceding was
  577.       not!). So not much else to say. Any specific questions? Feel free to
  578.       contact me!